<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Ajax extends Controller {
	public function action_submenu() {
		if (!$this->request->is_ajax()) {
			die('No direct script access.');
		}

		$submenu = ORM::factory('Menu')->get_submenu($this->request->post('id'));
		$data = '';

		foreach ($submenu as $key => $item) {
			$data .= '<div style="padding: 5px"><a href="'.URL::site($item->link).'">'.$item->title.'</a></div>';
		}


		echo json_encode(array('status' => 'ok', 'data' => $data));
	}
}